import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace RoomUsageApi {
  /** 房间使用记录信息 */
  export interface RoomUsage {
    id: number; // 主键ID
    roomNumber?: string; // 房间号
    billId?: number; // 账单ID
    usageType: string; // 使用类型
    startTime?: string | Dayjs; // 开始时间
    endTime: string | Dayjs; // 结束时间
    durationMinutes: number; // 使用时长(分钟)
    occupancyCount: number; // 占用人数
    status: string; // 状态
    operatorId: number; // 操作员ID
    operatorName: string; // 操作员姓名
    remarks: string; // 备注
  }
}

/** 查询房间使用记录分页 */
export function getRoomUsagePage(params: PageParam) {
  return requestClient.get<PageResult<RoomUsageApi.RoomUsage>>(
    '/spa/room-usage/page',
    { params },
  );
}

/** 查询房间使用记录详情 */
export function getRoomUsage(id: number) {
  return requestClient.get<RoomUsageApi.RoomUsage>(
    `/spa/room-usage/get?id=${id}`,
  );
}

/** 新增房间使用记录 */
export function createRoomUsage(data: RoomUsageApi.RoomUsage) {
  return requestClient.post('/spa/room-usage/create', data);
}

/** 修改房间使用记录 */
export function updateRoomUsage(data: RoomUsageApi.RoomUsage) {
  return requestClient.put('/spa/room-usage/update', data);
}

/** 删除房间使用记录 */
export function deleteRoomUsage(id: number) {
  return requestClient.delete(`/spa/room-usage/delete?id=${id}`);
}

/** 导出房间使用记录 */
export function exportRoomUsage(params: any) {
  return requestClient.download('/spa/room-usage/export-excel', { params });
}
